package nc.ui.cmp.applaybill.command;

import nc.ui.cmp.applaybill.ClientUI;
import nc.ui.cmp.applaybill.MyEventHandler;
import nc.ui.cmp.applaybill.common.UIUtil;
import nc.ui.pub.ButtonObject;
import nc.ui.trade.bocommand.IButtonCommand;
import nc.ui.trade.button.IBillButton;
import nc.ui.trade.controller.IControllerBase;
import nc.ui.trade.manage.BillManageUI;
import nc.ui.trade.manage.ManageEventHandler;
import nc.vo.cmp.applaybill.ApplyBillVO;
import nc.vo.pub.AggregatedValueObject;

public class CopyBoCommand extends ManageEventHandler implements IButtonCommand {

	public CopyBoCommand(BillManageUI billUI, IControllerBase control) {
		super(billUI, control);
	}

	public void execute(ButtonObject bo) throws Exception {
		ClientUI clientUI = (ClientUI)getBillUI();
		AggregatedValueObject onlyOneBean = UIUtil.getOnlyOneBean(clientUI);
		ApplyBillVO copyBean = UIUtil.getCopyBean((ApplyBillVO) onlyOneBean.getParentVO(), UIUtil.convertToFunCode(clientUI.getUiContext().getNodeNo()));
		onlyOneBean.setParentVO(copyBean);
		((MyEventHandler)clientUI.getHandler()).getCommands().get(IBillButton.Edit).execute(null);
		getBillCardPanelWrapper().setCardData(onlyOneBean);
	}

}
